#pragma once
#ifndef __G_COORD_FRAME_2_H__
#define __G_COORD_FRAME_2_H__

#include "GUtilities/GTypes.h"

#include "GVector2.h"
#include "GMatrix3x3.h"
#include "GUtilities/GBitContainer.h"

namespace GMath
{
	typedef GUtil::GFlag				GFrame2DirtyFlags;
	#define G_F2DF_DIRTY_TRANSFORM		0x0001
	#define G_F2DF_DIRTY_RIGHT			0x0002
	#define G_F2DF_DIRTY_UP				0x0004
	#define G_F2DF_DIRTY_AXIS			G_F2DF_DIRTY_RIGHT | G_F2DF_DIRTY_UP


	class GCoordFrame2
	{
		static const GCoordFrame2	Identitiy;

	protected:
		GVector2					Scale;
		GVector2					Position;
		float						Rotation;
		
		mutable GMatrix3x3			Transformation;

		mutable GVector2			Right;
		mutable GVector2			Up;

		mutable GFrame2DirtyFlags	Flags;

		virtual void				OnTransformChange();

	public:
									GCoordFrame2();
									GCoordFrame2(const GCoordFrame2& Frame);
									GCoordFrame2(const GVector2& Scale, float Rotation, const GVector2& Position);
		virtual						~GCoordFrame2();

		GFrame2DirtyFlags			GetFlags() const;

		void						SetScale(const GVector2& NewScale);
		const GVector2&				GetScale() const;

		void						SetPosition(const GVector2& NewPosition);
		const GVector2&				GetPosition() const;

		void						SetRotation(float NewRotation);
		float						GetRotation() const;

		void						SetTransformation(const GMatrix3x3& Matrix);
		const GMatrix3x3&			GetTransformation() const;

		const GVector2&				GetRight() const;
		const GVector2&				GetUp() const;

		const GCoordFrame2&			operator = (const GCoordFrame2& Frame);

	};

}

#endif